﻿<UserControl x:Class="Squiggle.UI.Controls.FilterTextBox"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <UserControl.Resources>
        <Style x:Key="BorderStyle" TargetType="{x:Type Border}">
            <Setter Property="BorderBrush" Value="#FFBFCBD8" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="CornerRadius" Value="3" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
        </Style>

        <Style x:Key="TextStyle" TargetType="{x:Type TextBox}">
            <Setter Property="Margin" Value="2,1,2,2" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="BorderBrush" Value="{x:Null}" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>        
        <BooleanToVisibilityConverter x:Key="booltoVisibility" />
    </UserControl.Resources>
    <Border Style="{StaticResource BorderStyle}">
        <DockPanel >
            <Button TabIndex="1" x:Name="btnCancel" Visibility="{Binding Path=IsFocusedOrNotEmpty, Converter={StaticResource booltoVisibility}}" DockPanel.Dock="Right" 
                    VerticalContentAlignment="Top" Style="{DynamicResource CloseButtonStyle}" Click="btnCancel_Click" />
            <TextBox x:Name="txtFilter"
                         DockPanel.Dock="Left" Style="{StaticResource TextStyle}" 
                         TextChanged="txtFilter_TextChanged" GotFocus="txtFilter_GotFocus" LostFocus="txtFilter_LostFocus" />
        </DockPanel>
    </Border>

</UserControl>
